package com.shuyuntu.proposal.controller;

import com.shuyuntu.proposal.entity.Department;
import com.shuyuntu.proposal.security.UseSecurity;
import com.shuyuntu.proposal.service.DepartmentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by limeng on 16/6/12.
 */
@Controller
@RequestMapping("/department")
public class DepartmentController {

    /**
     * 获取部门列表
     * @param session injection
     * @return json-list
     */
    @RequestMapping(value = "/", method = RequestMethod.GET)
    @ResponseBody
    @UseSecurity(category = "01")
    public List<Department> getDepartmentList(HttpSession session) {
        List<Department> reqList = departmentService.getDepartmentList();
        return reqList;
    }

    /******* 注入 *******/
    @Resource
    DepartmentService departmentService;

    public DepartmentService getDepartmentService() {
        return departmentService;
    }

    public void setDepartmentService(DepartmentService departmentService) {
        this.departmentService = departmentService;
    }
}
